
/**
  ******************************************************************************
  * @file    delay.c
  * @author  花溪村长
  * @version V1.0
  * @date    18-8-2015
  * @brief   This file contains all the functions prototypes for the GPIO 
  *          firmware library.
  ******************************************************************************
**/ 
#include "delay.h"
u8 times = 0;
void SysTick_Handler()
{
   times = 1;
}
void delay_ms_s(u16 nms)
{	 		  	  		   
  SysTick_Config((SystemCoreClock/1000)*nms);
  while(!times);
  times = 0;
  SysTick->CTRL =0x00;       
 	  	    
}

void delay_ms(u16 nms)
{
  u8 i ;
  for(i=0;i<100;i++)
  {
    if((nms -419)>=0)
    {
      delay_ms_s(419);
      nms=nms -419;
    }
    else
    {
      delay_ms_s(nms);
      break;
    }
  } 
}

void delay_us(u32 nus)
{		
  SysTick_Config((SystemCoreClock/1000000)*nus);
  while(!times);
  times = 0;
  SysTick->CTRL =0x00;       
}

